﻿Imports System.ComponentModel
Public Class LayerConfig
    Implements INotifyPropertyChanged

    Private _layerName As String = String.Empty
    Private _layerLabel As String = String.Empty
    Private _layerForm As String = String.Empty
    Private _layerTable As String = String.Empty
    Private _layerActivated As Boolean = False
    Dim siteDAO As SiteDAO = New SiteDAO()
    Sub New(ByVal vlayerName As String, ByVal vlayerLabel As String, ByVal vlayerActivated As Boolean, ByVal vlayerForm As String _
            , ByVal vlayerTable As String)
        _layerName = vlayerName
        _layerLabel = vlayerLabel
        _layerActivated = vlayerActivated
        _layerForm = vlayerForm
        _layerTable = vlayerTable
    End Sub
    Public Event PropertyChanged As PropertyChangedEventHandler _
        Implements INotifyPropertyChanged.PropertyChanged

    Private Sub NotifyPropertyChanged(ByVal info As String)
        RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs(info))
    End Sub

    Public Property LayerName() As String
        Get
            Return Me._layerName
        End Get
        Set(ByVal value As String)
            If Not (value = _layerName) Then
                Me._layerName = value
                NotifyPropertyChanged("LayerName")
            End If
        End Set
    End Property

    Public Property LayerLabel() As String
        Get
            Return Me._layerLabel
        End Get
        Set(ByVal value As String)
            If Not (value = _layerLabel) Then
                Me._layerLabel = value
                NotifyPropertyChanged("LayerLabel")
            End If
        End Set
    End Property

    Public Property LayerActivated() As Boolean
        Get
            Return Me._layerActivated
        End Get
        Set(ByVal value As Boolean)
            If Not (value = _layerActivated) Then
                Me._layerActivated = value
                NotifyPropertyChanged("LayerActivated")
                siteDAO.updateConfigLayer(Me)
            End If
        End Set
    End Property

    Public Property LayerForm() As String
        Get
            Return Me._layerForm
        End Get
        Set(ByVal value As String)
            If Not (value = _layerForm) Then
                Me._layerForm = value
                NotifyPropertyChanged("LayerForm")
                siteDAO.updateConfigLayer(Me)
            End If
        End Set
    End Property

    Public Property LayerTable() As String
        Get
            Return Me._layerTable
        End Get
        Set(ByVal value As String)
            If Not (value = _layerTable) Then
                Me._layerTable = value
                NotifyPropertyChanged("LayerTable")
                siteDAO.updateConfigLayer(Me)
            End If
        End Set
    End Property
    Protected Overrides Sub Finalize()
        siteDAO = Nothing
    End Sub
End Class
